package com.oa.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.oa.bean.FileCabinet;
import com.oa.bean.PublicFile;
import com.oa.bean.Section;
import com.oa.dao.FileCabinetDao;
import com.oa.dao.PersonalDao;
import com.oa.service.FileCabinetService;

@Service
public class FileCabinetServiceImpl implements FileCabinetService {

	@Resource
	FileCabinetDao fileCabinetDao;
	
	@Autowired
	PersonalDao personalDao;
	
	@Override
	public String addMyFile(FileCabinet fileCabinet) {
		// TODO Auto-generated method stub
		Integer result = fileCabinetDao.insertMyFile(fileCabinet);
		if(result!=0){
			return "true";
		}
		return "false";
	}

	@Override
	public String moveMyFile(Integer fid) {
		// TODO Auto-generated method stub
		Integer result = fileCabinetDao.deleteMyFile(fid);
		if(result!=0){
			return "true";
		}
		return "false";
	}

	@Override
	public List<FileCabinet> getMyFileList(Integer uid) {
		// TODO Auto-generated method stub
		List<FileCabinet> list = fileCabinetDao.selectMyFile(uid);
		return list;
	}

	@Override
	public String addPublicFile(PublicFile publicFile) {
		// TODO Auto-generated method stub
		Integer result = fileCabinetDao.insertPublicFile(publicFile);
		if(result!=0){
			return "true";
		}
		return "false";
	}

	@Override
	public Map<String,Object> managePublicFileList(Integer deptno,Integer condition) {
		// TODO Auto-generated method stub
		Map<String,Object>map = new HashMap<>();
		map.put("deptno", deptno);
		map.put("condition", condition);
		List<PublicFile> list = fileCabinetDao.selectPublicFile(map);
		List<Section> sectionList = personalDao.selectSectionList();
		Map<String,Object> result = new HashMap<>();
		result.put("fileList", list);
		result.put("sectionList", sectionList);
		return result;
	}

	@Override
	public List<PublicFile> getPublicFileList(Integer deptno) {
		// TODO Auto-generated method stub
		List<PublicFile> list = fileCabinetDao.lookPublicFileList(deptno);
		return list;
	}

	@Override
	public String movePublicFile(Integer id) {
		// TODO Auto-generated method stub
		Integer result = fileCabinetDao.deletePublicFile(id);
		if(result!=0){
			return "true";
		}
		return "false";
	}
	
	
	

}
